<form>
<?php
$url = $_GET['url'];
$xmltext = file_get_contents($url);
try {
    $xml = new SimpleXMLElement($xmltext);
} catch (Exception $e) {
    die("Unable to parse xml: $url");
}
require_once('../lib/messages.php');

$messagesurl = find_message_bundle($url, $xml, 'en');
if ($messageurl !== false) load_message_bundle($messagesurl);

$id = 0;

foreach ($xml->UserPref as $pref) {
    echo "<b>".translate($pref['display_name'])."</b> ";
    switch($pref['datatype']) {
        case 'enum':
        echo "<select name=\"{$pref['name']}\">";

        foreach ($pref->EnumValue as $v) {
            if (isset($v['display_value'])) {
                $display_value = $v['display_value'];
            } else {
                $display_value = $v['value'];
            }
            if ("{$v['value']}" == $default) echo "<option value=\"{$v['value']}\" SELECTED>$display_value</option>";
            else echo "<option value=\"{$v['value']}\">$display_value</option>";
        }
        echo "</select>\n";
        break;

        case 'bool':
        if ("{$pref['default_value']}" == 'true') { $t = 'SELECTED'; $f = ''; } else { $t = ''; $f = 'SELECTED'; }
        echo "<select name=\"{$pref['name']}\">";
        echo "<option value=\"true\" $t>True</option>";
        echo "<option value=\"false\" $f>False</option>";
        echo "</select>";
        break;

        case 'hidden':
        echo "<input type=\"hidden\" name=\"{$pref['name']}\" value=\"{$pref['default_value']}\" />";

        default:

    }
    echo "<br/>";
}

?>
<br/>
<input type="Submit" value="Save Preferences"/>
</form>